/**
 * 版本1.1
 * 更新说明：读取、设置配置
 * 
 */



var JSSDKProtocol = 'qikecn://';

function exec(method, propertys){
	window.location.href = JSSDKProtocol + 'exec?propertys=' + propertys + '&method=' + method;
}

//系统toast信息
function JSSDKToast(content){
	var method = 'JSSDKToast';
	var propertysObj = {
		'content':content
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用系统关闭当前页面
function JSSDKFinishPage(){
	var method = 'JSSDKFinishPage';
	var propertysObj = {};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用系统关闭当前页面
function JSSDKFinishPageForResult(requestCode, data){
	var method = 'JSSDKFinishPageForResult';
	var propertysObj = {
		'requestCode':requestCode,
		'data':data
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//系统提示框
function JSSDKAlert(title, content, btnTxt){
	var method = 'JSSDKAlert';
	var propertysObj = {
		'title':title,
		'content':content,
		'btnTxt':btnTxt
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用系统发送短信
function JSSDKSendSms(address, content){
	var method = 'JSSDKSendSms';
	var propertysObj = {
		'address':address,
		'content':content
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用系统呼叫
function JSSDKCallPhone(address){
	var method = 'JSSDKCallPhone';
	var propertysObj = {
		'address':address
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用系统打开网页
function JSSDKOpenUrlBySystem(url){
	var method = 'JSSDKOpenUrlBySystem';
	var propertysObj = {
		'url':url
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//读取配置-int
var JSSDKGetPreferenceIntCallback;
function JSSDKGetPreferenceInt(key, defaultValue, JSSDKGetPreferenceIntFunc){
	JSSDKGetPreferenceIntCallback = JSSDKGetPreferenceIntFunc;
	var method = 'JSSDKGetPreferenceInt';
	var propertysObj = {
		'key':key,
		'defaultValue':defaultValue
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//读取配置-long
var JSSDKGetPreferenceLongCallback;
function JSSDKGetPreferenceLong(key, defaultValue, JSSDKGetPreferenceLongFunc){
	JSSDKGetPreferenceLongCallback = JSSDKGetPreferenceLongFunc;
	var method = 'JSSDKGetPreferenceLong';
	var propertysObj = {
		'key':key,
		'defaultValue':defaultValue
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//读取配置-float
var JSSDKGetPreferenceFloatCallback;
function JSSDKGetPreferenceFloat(key, defaultValue, JSSDKGetPreferenceFloatFunc){
	JSSDKGetPreferenceFloatCallback = JSSDKGetPreferenceFloatFunc;
	var method = 'JSSDKGetPreferenceFloat';
	var propertysObj = {
		'key':key,
		'defaultValue':defaultValue
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//读取配置-boolean
var JSSDKGetPreferenceBooleanCallback;
function JSSDKGetPreferenceBoolean(key, defaultValue, JSSDKGetPreferenceBooleanFunc){
	JSSDKGetPreferenceBooleanCallback = JSSDKGetPreferenceBooleanFunc;
	var method = 'JSSDKGetPreferenceBoolean';
	var propertysObj = {
		'key':key,
		'defaultValue':defaultValue
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//读取配置-string
var JSSDKGetPreferenceStringCallback;
function JSSDKGetPreferenceString(key, defaultValue, JSSDKGetPreferenceStringFunc){
	JSSDKGetPreferenceStringCallback = JSSDKGetPreferenceStringFunc;
	var method = 'JSSDKGetPreferenceString';
	var propertysObj = {
		'key':key,
		'defaultValue':defaultValue
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//图片预览-pics多个图片英文逗号隔开
function JSSDKImagePreview(pics){
	var method = 'JSSDKImagePreview';
	var propertysObj = {
		'pics':pics
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//第三方分享
var JSSDKShareThirdPartyCallback;
function JSSDKShareThirdParty(title, content, pic, url, JSSDKShareThirdPartyFunc){
	JSSDKShareThirdPartyCallback = JSSDKShareThirdPartyFunc;
	var method = 'JSSDKShareThirdParty';
	var propertysObj = {
		'title':title,
		'content':content,
		'pic':pic,
		'url':url
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用内置浏览器打开网页
function JSSDKOpenUrl(title, url){
	JSSDKOpenUrl(title, url, true, true, true);
}

//调用内置浏览器打开网页
function JSSDKOpenUrl(title, url, showLoadingDialog, showMenu, showTitleLayout){
	JSSDKOpenUrl(title, url, showLoadingDialog, showMenu, showTitleLayout, false, 0, null);
}

//调用内置浏览器打开网页
function JSSDKOpenUrl(title, url, showLoadingDialog, showMenu, showTitleLayout, needResult, requestCode, JSSDKOpenUrlCallbackFunc){
	JSSDKOpenUrl(title, url, showLoadingDialog, showMenu, showTitleLayout, needResult, requestCode, JSSDKOpenUrlCallbackFunc, 0);
}

//调用内置浏览器打开网页
var JSSDKOpenUrlCallback;
//var JSSDKMenuClickCallback;
//menuType 为1是添加图标，为2是保存图标，为3是删除图标，为4是分享图标。
function JSSDKOpenUrl(title, url, showLoadingDialog, showMenu, showTitleLayout, needResult, requestCode, JSSDKOpenUrlCallbackFunc, menuType){
	if(JSSDKOpenUrlCallbackFunc)
		JSSDKOpenUrlCallback = JSSDKOpenUrlCallbackFunc;
	/*if(JSSDKMenuClickCallbackFunc)
		JSSDKMenuClickCallback = JSSDKMenuClickCallbackFunc;*/
	var method = 'JSSDKOpenUrl';
	var propertysObj = {
		'title':title,
		'url':url,
		'showLoadingDialog':showLoadingDialog,
		'showMenu':showMenu,
		'menuType':menuType,
		'showTitleLayout':showTitleLayout,
		'needResult':needResult,
		'requestCode':requestCode
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//获取登录信息
var JSSDKGetLoginInfoCallback;
function JSSDKGetLoginInfo(JSSDKGetLoginInfoCallbackFunc){
	JSSDKGetLoginInfoCallback = JSSDKGetLoginInfoCallbackFunc;
	var method = 'JSSDKGetLoginInfo';
	var propertysObj = {}
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//获取系统信息
var JSSDKGetDeviceInfoCallback;
function JSSDKGetDeviceInfo(JSSDKGetDeviceInfoCallbackFunc){
	JSSDKGetDeviceInfoCallback = JSSDKGetDeviceInfoCallbackFunc;
	var method = 'JSSDKGetDeviceInfo';
	var propertysObj = {}
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//调用分享分享
function JSSDKShareTxtBySystem(title, content){
	var method = 'JSSDKShareTxtBySystem';
	var propertysObj = {
		'title':title,
		'content':content
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}


//显示加载中
function JSSDKShowProgressDialog(content){
	var method = 'JSSDKShowProgressDialog';
	var propertysObj = {
		'content':content
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//隐藏加载中
function JSSDKDismissProgressDialog(){
	var method = 'JSSDKDismissProgressDialog';
	var propertysObj = {};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//自定义标题
function JSSDKSetCustomTitle(title){
	var method = 'JSSDKSetCustomTitle';
	var propertysObj = {
		'title':title
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//跳转到登录页面
function JSSDKToLoginPage(){
	var method = 'JSSDKToLoginPage';
	var propertysObj = {};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//跳转到注册页面
function JSSDKToRegisterPage(){
	var method = 'JSSDKToRegisterPage';
	var propertysObj = {};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//二维码扫描
var JSSDKScanQRCodeCallback;
function JSSDKScanQRCode(JSSDKScanQRCodeCallbackFunc){
	JSSDKScanQRCodeCallback = JSSDKScanQRCodeCallbackFunc;
	var method = 'JSSDKScanQRCode';
	var propertysObj = {};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//上传图片，成功返回服务器临时文件名称
var JSSDKUploadPictureCallback;
function JSSDKUploadPicture(imgCount, JSSDKUploadPictureFunc){
	JSSDKUploadPictureCallback = JSSDKUploadPictureFunc;
	var method = 'JSSDKUploadPicture';
	var propertysObj = {
		'imgCount':imgCount
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//支付宝支付
function JSSDKAlipay(orderSign){
	var method = 'JSSDKAlipay';
	var propertysObj = {
		'orderSign':orderSign
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//微信支付
function JSSDKWxpay(appId, partnerId, prepayId, nonceStr, timeStamp, packageStr, sign){
	var method = 'JSSDKWxpay';
	var propertysObj = {
		'appId':appId,
		'partnerId':partnerId,
		'prepayId':prepayId,
		'nonceStr':nonceStr,
		'timeStamp':timeStamp,
		'package':packageStr,
		'sign':sign
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

//微信支付
function JSSDKWxpay(appId, partnerId, prepayId, nonceStr, timeStamp, packageStr, sign){
	var method = 'JSSDKWxpay';
	var propertysObj = {
		'appId':appId,
		'partnerId':partnerId,
		'prepayId':prepayId,
		'nonceStr':nonceStr,
		'timeStamp':timeStamp,
		'package':packageStr,
		'sign':sign
	};
	var propertys = BASE64.encoder(JSON.stringify(propertysObj));
	exec(method, propertys);
}

